home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
music
/
309
/
gfa
/
gfacust.gfa
(
.txt
)
< prev
next >
Wrap
GFA-BASIC Atari
|
1988-09-19
|
27KB
|
970 lines
' GFACUST.GFA
'
' Customizing program for GFA BASIC 3.0
' Version 1.0 (09/88)
' By Don Bush
' GEnie: D.BUSH
'
' This program may be redistributed freely for non-profit purposes only.
'
'
' First we force GEM to redraw it's desktop
~WIND_GET(0,4,dx%,dy%,dw%,dh%)
~FORM_DIAL(3,dx%,dy%,dw%,dh%,dx%,dy%,dw%,dh%)
'
' Make sure we are in the proper resolution
IF (XBIOS(4)=0)
~FORM_ALERT(1,"[1][This program only runs|in medium or high|resolution][OK]")
END
ENDIF
'
' Load the resource file
IF (RSRC_LOAD("GFACUST.RSC")=0)
~FORM_ALERT(1,"[1][Could not find|GFACUST.RSC][OK]")
END
ENDIF
'
' Initialize global variables which will hold our customization info
@init_globals
'
' Initialize the resource file index variables and the pointers to
' the resource trees.
@init_index_vars
@init_tree_pointers
'
' Display the menu bar
~MENU_BAR(menu_tree%,1)
'
' Install our error trapping procedure
ON ERROR GOSUB error_exit
'
' Go do our main program loop
@process_events
'
' Remove the menu bar, free the resource, and end the program
~MENU_BAR(menu_tree%,0)
~RSRC_FREE()
CLS
END
'
'
> PROCEDURE init_globals
basic_file$="GFABASIC.PRG"
basro_file$="GFABASRO.PRG"
'
clear_screen_ba!=TRUE
clear_screen_ro!=TRUE
'
auto_program$=CHR$(0)
'
DIM var_type%(26)
ARRAYFILL var_type%(),0
DIM var_type_idx%(6)
var_type_idx%(0)=0
var_type_idx%(1)=1
var_type_idx%(2)=3
var_type_idx%(3)=2
var_type_idx%(4)=8
var_type_idx%(5)=9
vt_char$="#$!%&|"
'
DIM editor_colors%(4)
editor_colors%(0)=&H777
editor_colors%(1)=&H700
editor_colors%(2)=&H70
editor_colors%(3)=&H0
'
default_deflist%=0
'
default_pl%=60
default_ll%=80
default_he$=CHR$(0)
default_fo$=CHR$(0)
default_in$=CHR$(0)
default_ff$=CHR$(0)
RETURN
> PROCEDURE init_index_vars
menu%=0! menu tree
tdesk%=3! TITLE in tree MENU
tfile%=4! TITLE in tree MENU
tbasic%=5! TITLE in tree MENU
tbasro%=6! TITLE in tree MENU
iabout%=9! STRING in tree MENU
irdbasic%=18! STRING in tree MENU
iupbasic%=19! STRING in tree MENU
irdbasro%=21! STRING in tree MENU
iupbasro%=22! STRING in tree MENU
iquit%=24! STRING in tree MENU
ibaerase%=26! STRING in tree MENU
ibatypes%=27! STRING in tree MENU
ibacolor%=28! STRING in tree MENU
ibadlist%=29! STRING in tree MENU
iballist%=30! STRING in tree MENU
iroerase%=32! STRING in tree MENU
irodeflt%=33! STRING in tree MENU
dabout%=1! form/dialog
derase%=2! form/dialog
dererase%=5! BOXTEXT in tree DERASE
dernoera%=6! BOXTEXT in tree DERASE
derok%=7! BUTTON in tree DERASE
dercancl%=8! BUTTON in tree DERASE
dvartype%=3! form/dialog
dvatypea%=5! BUTTON in tree DVARTYPE
dvaok%=31! BUTTON in tree DVARTYPE
dvacancl%=32! BUTTON in tree DVARTYPE
ddeflist%=4! form/dialog
dde0%=11! BUTTON in tree DDEFLIST
ddeok%=15! BUTTON in tree DDEFLIST
ddecancl%=16! BUTTON in tree DDEFLIST
dllist%=5! form/dialog
dllok%=2! BUTTON in tree DLLIST
dllcancl%=3! BUTTON in tree DLLIST
dllpl%=4! FTEXT in tree DLLIST
dllll%=5! FTEXT in tree DLLIST
dllhe%=6! FTEXT in tree DLLIST
dllfo%=7! FTEXT in tree DLLIST
dllin%=8! FTEXT in tree DLLIST
dllff%=9! FTEXT in tree DLLIST
dcolors%=6! form/dialog
dcobkup1%=5! BOXCHAR in tree DCOLORS
dcobkup3%=7! BOXCHAR in tree DCOLORS
dcobknum%=8! BUTTON in tree DCOLORS
dcobkdn1%=11! BOXCHAR in tree DCOLORS
dcobkdn3%=13! BOXCHAR in tree DCOLORS
dcotxup1%=17! BOXCHAR in tree DCOLORS
dcotxup3%=19! BOXCHAR in tree DCOLORS
dcotxnum%=20! BUTTON in tree DCOLORS
dcotxdn1%=23! BOXCHAR in tree DCOLORS
dcotxdn3%=25! BOXCHAR in tree DCOLORS
dcocrup1%=29! BOXCHAR in tree DCOLORS
dcocrup3%=31! BOXCHAR in tree DCOLORS
dcocrnum%=32! BUTTON in tree DCOLORS
dcocrdn1%=35! BOXCHAR in tree DCOLORS
dcocrdn3%=37! BOXCHAR in tree DCOLORS
dcoblup1%=41! BOXCHAR in tree DCOLORS
dcoblup3%=43! BOXCHAR in tree DCOLORS
dcoblnum%=44! BUTTON in tree DCOLORS
dcobldn1%=47! BOXCHAR in tree DCOLORS
dcobldn3%=49! BOXCHAR in tree DCOLORS
dcook%=50! BUTTON in tree DCOLORS
dcocancl%=51! BUTTON in tree DCOLORS
dverify%=7! form/dialog
dvetext%=2! FTEXT in tree DVERIFY
dveok%=3! BUTTON in tree DVERIFY
dvecancl%=4! BUTTON in tree DVERIFY
dprogram%=8! form/dialog
dprok%=2! BUTTON in tree DPROGRAM
dprcancl%=3! BUTTON in tree DPROGRAM
dprfsel%=7! BOXTEXT in tree DPROGRAM
dprtext%=9! FTEXT in tree DPROGRAM
dcolrmon%=9! form/dialog
dcmnorm%=2! BOX in tree DCOLRMON
dcminvrs%=4! BOX in tree DCOLRMON
dcmok%=7! BUTTON in tree DCOLRMON
dcmcancl%=8! BUTTON in tree DCOLRMON
aexistba%=0! Alert string index
awarnbas%=1! Alert string index
awarnro%=2! Alert string index
aexistro%=3! Alert string index
RETURN
> PROCEDURE init_tree_pointers
' Find the addresses of the menu and dialog trees
~RSRC_GADDR(0,menu%,menu_tree%)
~RSRC_GADDR(0,dabout%,dabout_tree%)
~RSRC_GADDR(0,derase%,derase_tree%)
~RSRC_GADDR(0,dvartype%,dvartype_tree%)
~RSRC_GADDR(0,ddeflist%,ddeflist_tree%)
~RSRC_GADDR(0,dllist%,dllist_tree%)
~RSRC_GADDR(0,dprogram%,dprogram_tree%)
~RSRC_GADDR(0,dcolors%,dcolors_tree%)
~RSRC_GADDR(0,dverify%,dverify_tree%)
~RSRC_GADDR(0,dcolrmon%,dcolrmon_tree%)
'
' Find the addresses of the alert strings
~RSRC_GADDR(5,aexistba%,aexistba_alert%)
~RSRC_GADDR(5,aexistro%,aexistro_alert%)
~RSRC_GADDR(5,awarnbas%,awarnbas_alert%)
~RSRC_GADDR(5,awarnro%,awarnro_alert%)
RETURN
> PROCEDURE process_events
LOCAL msg$,message_id&,menu_title&,menu_item&
'
' Initialize our message buffer and some variables to make it convenient
msg$=SPACE$(16)
ABSOLUTE message_id&,V:msg$
ABSOLUTE menu_title&,V:msg$+6
ABSOLUTE menu_item&,V:msg$+8
'
' This loop will be executed until the user selects the 'Quit' menu item
DO
' Wait for the user to select a menu item
~EVNT_MESAG(V:msg$)
IF message_id&=10 ! 10 = a menu message
EXIT IF menu_item&=iquit%
@process_menu_selection(menu_title&,menu_item&)
' Reset the menu title to display normally
~MENU_TNORMAL(menu_tree%,menu_title&,1)
ENDIF
LOOP
RETURN
> PROCEDURE process_menu_selection(title%,item%)
' This procedure simply calls various procedures based upon the users menu
' selectons.
LOCAL button%
SELECT item%
CASE iabout%
@do_dialog(dabout_tree%,0,button%)
CASE irdbasic%
@read_gfabasic
CASE iupbasic%
@update_gfabasic
CASE irdbasro%
@read_gfabasro
CASE iupbasro%
@update_gfabasro
CASE ibaerase%
@do_erase_dialog(1)
CASE iroerase%
@do_erase_dialog(0)
CASE ibatypes%
@do_vartype_dialog
CASE ibacolor%
IF XBIOS(4)=2
@do_mono_color_dialog
ELSE
@do_colors_dialog
ENDIF
CASE ibadlist%
@do_deflist_dialog
CASE iballist%
@do_llist_dialog
CASE irodeflt%
@do_program_dialog
ENDSELECT
RETURN
> PROCEDURE read_gfabasic
' This procedure reads the customization information from a GFABASIC.PRG file
LOCAL i%,j%,k%,button%
DO
@select_file("PRG","Select GFABASIC.PRG to read...",basic_file$,button%)
EXIT IF button%=0 OR EXIST(basic_file$)
~FORM_ALERT(1,CHAR{aexistba_alert%})
LOOP
IF button% !if user pressed ok
OPEN "I",#1,basic_file$
'
' Read the screen erase value
SEEK #1,31
IF INP(#1)=ASC("E")
clear_screen_ba!=TRUE
ELSE
clear_screen_ba!=FALSE
ENDIF
'
' Read the variable types
SEEK #1,32
FOR i%=0 TO 25
j%=INP(#1)
FOR k%=0 TO 5
EXIT IF var_type_idx%(k%)=j%
NEXT k%
var_type%(i%)=k%
NEXT i%
'
' Read the editor colors
SEEK #1,58
FOR i%=0 TO 3
editor_colors%(i%)=INP(#1)*256+INP(#1)
NEXT i%
'
' Read the DEFLIST value
SEEK #1,80
default_deflist%=INP(#1)*256+INP(#1)
'
' Read the LLIST line length and page length values
SEEK #1,82
default_pl%=INP(#1)*256+INP(#1)
SEEK #1,86
default_ll%=INP(#1)*256+INP(#1)
'
' Read the LLIST header string
SEEK #1,88
default_he$=""
FOR i%=1 TO 32
j%=INP(#1)
EXIT IF j%=13 OR j%=0
default_he$=default_he$+CHR$(j%)
NEXT i%
default_he$=default_he$+CHR$(0)
'
' Read the LLIST footer string
SEEK #1,120
default_fo$=""
FOR i%=1 TO 32
j%=INP(#1)
EXIT IF j%=13 OR j%=0
default_fo$=default_fo$+CHR$(j%)
NEXT i%
default_fo$=default_fo$+CHR$(0)
'
' Read the LLIST initialization string
SEEK #1,152
default_in$=""
FOR i%=1 TO 32
j%=INP(#1)
EXIT IF j%=13 OR j%=0
default_in$=default_in$+CHR$(j%)
NEXT i%
default_in$=default_in$+CHR$(0)
'
' Read the LLIST formfeed string
SEEK #1,184
default_ff$=""
FOR i%=1 TO 32
j%=INP(#1)
EXIT IF j%=13 OR j%=0
default_ff$=default_ff$+CHR$(j%)
NEXT i%
default_ff$=default_ff$+CHR$(0)
'
CLOSE #1
ENDIF
RETURN
> PROCEDURE update_gfabasic
' This procedure writes the customization info to a GFABASIC.PRG file
LOCAL i%,button%
~FORM_ALERT(1,CHAR{awarnbas_alert%})
DO
@select_file("PRG","Select GFABASIC.PRG to customize...",basic_file$,button%)
EXIT IF button%=0 OR EXIST(basic_file$)
~FORM_ALERT(1,CHAR{aexistba_alert%})
LOOP
IF button% ! if user pressed the OK button
' Warn the user
CHAR{{OB_SPEC(dverify_tree%,dvetext%)}}=basic_file$
@do_dialog(dverify_tree%,0,button%)
IF button%=dveok%
OPEN "U",#1,basic_file$
'
' Write the clear screen flag
SEEK #1,31
IF clear_screen_ba!
OUT #1,ASC("E")
ELSE
OUT #1,ASC("H")
ENDIF
'
' Write the variable types
SEEK #1,32
FOR i%=0 TO 25
OUT #1,var_type_idx%(var_type%(i%))
NEXT i%
'
' Write the editor colors
SEEK #1,58
FOR i%=0 TO 3
PRINT #1,MKI$(editor_colors%(i%));
NEXT i%
'
' Write the DEFLIST value
SEEK #1,80
PRINT #1,MKI$(default_deflist%);
'
' Write the LLIST page length and line length values
SEEK #1,82
PRINT #1,MKI$(default_pl%);
SEEK #1,86
PRINT #1,MKI$(default_ll%);
'
' Write the LLIST header string
SEEK #1,88
IF LEN(default_he$)<1
OUT #1,0
ELSE
PRINT #1;default_he$+CHR$(13);
ENDIF
'
' Write the LLIST footer string
SEEK #1,120
IF LEN(default_fo$)<1
OUT #1,0
ELSE
PRINT #1;default_fo$+CHR$(13);
ENDIF
'
' Write the LLIST initialization string
SEEK #1,152
IF LEN(default_in$)<1
OUT #1,0
ELSE
PRINT #1;default_in$+CHR$(13);
ENDIF
'
' Write the LLIST formfeed string
SEEK #1,184
IF LEN(default_ff$)<1
OUT #1,0
ELSE
PRINT #1;default_ff$+CHR$(13);
ENDIF
'
CLOSE #1
ENDIF
ENDIF
RETURN
> PROCEDURE read_gfabasro
' This procedure reads the customization info from a GFABASRO.PRG file
LOCAL i%,j%,k%,button%
DO
@select_file("PRG","Select GFABASRO.PRG to read...",basro_file$,button%)
EXIT IF button%=0 OR EXIST(basro_file$)
~FORM_ALERT(1,CHAR{aexistro_alert%})
LOOP
IF button%
OPEN "I",#1,basro_file$
'
' Read the clear-screen flag
SEEK #1,31
IF INP(#1)=ASC("E")
clear_screen_ro!=TRUE
ELSE
clear_screen_ro!=FALSE
ENDIF
'
' Read the name of the auto program
SEEK #1,32
auto_program$=""
FOR i%=1 TO 63
j%=INP(#1)
EXIT IF j%=0
auto_program$=auto_program$+CHR$(j%)
NEXT i%
auto_program$=auto_program$+CHR$(0)
'
CLOSE #1
ENDIF
RETURN
> PROCEDURE update_gfabasro
' This procedure writes the customization info to a GFABASRO.PRG file
LOCAL i%,button%
~FORM_ALERT(1,CHAR{awarnro_alert%})
DO
@select_file("PRG","Select GFABASRO.PRG to customize...",basro_file$,button%)
EXIT IF button%=0 OR EXIST(basro_file$)
~FORM_ALERT(1,CHAR{aexistro_alert%})
LOOP
IF button%
' Warn the user
CHAR{{OB_SPEC(dverify_tree%,dvetext%)}}=basro_file$
@do_dialog(dverify_tree%,0,button%)
IF button%=dveok%
OPEN "U",#1,basro_file$
'
' Write the clear-screen flag
SEEK #1,31
IF clear_screen_ro!
OUT #1,ASC("E")
ELSE
OUT #1,ASC("H")
ENDIF
'
' Write the auto-program name
SEEK #1,32
PRINT #1;auto_program$;CHR$(0);
'
CLOSE #1
ENDIF
ENDIF
RETURN
> PROCEDURE do_erase_dialog(flag%)
LOCAL status!,button%
' Flag% is 1 if we are editing the default screen erase for GFABASIC.PRG
' it is 0 for GFABASRO.PRG
IF flag%
status!=clear_screen_ba!
ELSE
status!=clear_screen_ro!
ENDIF
' Initialize the radio buttons
IF status!
OB_STATE(derase_tree%,dererase%)=BSET(OB_STATE(derase_tree%,dererase%),0)
OB_STATE(derase_tree%,dernoera%)=BCLR(OB_STATE(derase_tree%,dernoera%),0)
ELSE
OB_STATE(derase_tree%,dererase%)=BCLR(OB_STATE(derase_tree%,dererase%),0)
OB_STATE(derase_tree%,dernoera%)=BSET(OB_STATE(derase_tree%,dernoera%),0)
ENDIF
' animate the dialog
do_dialog(derase_tree%,0,button%)
IF button%=derok%
' Save users new screen-erase choice
status!=BTST(OB_STATE(derase_tree%,dererase%),0)
IF flag%
clear_screen_ba!=status!
ELSE
clear_screen_ro!=status!
ENDIF
ENDIF
RETURN
> PROCEDURE do_vartype_dialog
LOCAL i%,x%,y%,w%,h%,t$
'
' Make sure button texts reflect current variable types
FOR i%=0 TO 25
t$=CHAR{OB_SPEC(dvartype_tree%,dvatypea%+i%)}
MID$(t$,3,1)=MID$(vt_char$,var_type%(i%)+1,1)
CHAR{OB_SPEC(dvartype_tree%,dvatypea%+i%)}=t$
NEXT i%
'
' Center and draw our dialog
~FORM_CENTER(dvartype_tree%,x%,y%,w%,h%)
~FORM_DIAL(0,0,0,0,0,x%,y%,w%,h%)
~OBJC_DRAW(dvartype_tree%,0,10,x%,y%,w%,h%)
'
DO
' Animate the dialog
button%=FORM_DO(dvartype_tree%,0)
' We mask off high bit of button% which is set by GEM if the button
' type was touchexit and the user double-clicked it.
button%=AND(button%,&H7FFF)
'
' Deselect button
OB_STATE(dvartype_tree%,button%)=BCLR(OB_STATE(dvartype_tree%,button%),0)
'
' Exit loop if user pressed OK or CANCEL
EXIT IF button%=dvaok% OR button%=dvacancl%
'
' Get old button text
t$=CHAR{OB_SPEC(dvartype_tree%,button%)}
'
' Find index of current type character in vt_char$ and add 1
i%=INSTR(vt_char$,MID$(t$,3,1))+1
' Make sure we did not go out of range
IF i%>LEN(vt_char$)
i%=1
ENDIF
'
' Update button text with new type character and redraw the button
MID$(t$,3,1)=MID$(vt_char$,i%,1)
CHAR{OB_SPEC(dvartype_tree%,button%)}=t$
~OBJC_DRAW(dvartype_tree%,button%,0,x%,y%,w%,h%)
'
' If the user is holding the button down then delay a bit to slow down
' the display
IF MOUSEK
PAUSE 12
ENDIF
LOOP
'
IF button%=dvaok% !if user pressed OK button
' update current variable types with values from button texts
FOR i%=0 TO 25
t$=MID$(CHAR{OB_SPEC(dvartype_tree%,dvatypea%+i%)},3,1)
var_type%(i%)=INSTR(vt_char$,t$)-1
NEXT i%
ENDIF
' Cause GEM to redraw area where our dialog was
~FORM_DIAL(3,0,0,0,0,x%,y%,w%,h%)
RETURN
'
> PROCEDURE do_colors_dialog
LOCAL button%,x%,y%,w%,h%
LOCAL red%,green%,blue%
LOCAL i%,temp%
LOCAL colr$
'
' Save current color register values so we can restore them later
@save_color_registers(colr$)
'
' Initialize our dialog to show current color info
@put_colors_into_dialog(dcolors_tree%,dcobknum%,editor_colors%(0))
@put_colors_into_dialog(dcolors_tree%,dcotxnum%,editor_colors%(3))
@put_colors_into_dialog(dcolors_tree%,dcocrnum%,editor_colors%(2))
@put_colors_into_dialog(dcolors_tree%,dcoblnum%,editor_colors%(1))
'
' Center and draw the dialog
~FORM_CENTER(dcolors_tree%,x%,y%,w%,h%)
~FORM_DIAL(0,0,0,0,0,x%,y%,w%,h%)
~OBJC_DRAW(dcolors_tree%,0,10,x%,y%,w%,h%)
' Now we set the colors into the color registers
@draw_rgb_boxes_and_show_color(dcolors_tree%,dcobknum%)
@draw_rgb_boxes_and_show_color(dcolors_tree%,dcotxnum%)
@draw_rgb_boxes_and_show_color(dcolors_tree%,dcocrnum%)
@draw_rgb_boxes_and_show_color(dcolors_tree%,dcoblnum%)
'
REPEAT
' Animate the dialog
button%=FORM_DO(dcolors_tree%,start%)
'
' The next line masks off high bit of exit button which is set if button
' was 'touchexit' and user double-clicked.
button%=AND(button%,&H7FFF)
'
SELECT button%
CASE dcobkup1% TO dcobkup3%,dcotxup1% TO dcotxup3%,dcocrup1% TO dcocrup3%,dcoblup1% TO dcoblup3%
' User selected an up arrow so we increment the r/g/b value and redraw
temp%=VAL(CHAR{OB_SPEC(dcolors_tree%,button%+3)})
IF temp%<7
ADD temp%,1
CHAR{OB_SPEC(dcolors_tree%,button%+3)}=STR$(temp%)
@draw_rgb_boxes_and_show_color(dcolors_tree%,button%+3)
ENDIF
PAUSE 12
CASE dcobkdn1% TO dcobkdn3%,dcotxdn1% TO dcotxdn3%,dcocrdn1% TO dcocrdn3%,dcobldn1% TO dcobldn3%
' User selected a down arrow so we decrement the r/g/b value and redraw
temp%=VAL(CHAR{OB_SPEC(dcolors_tree%,button%-3)})
IF temp%>0
SUB temp%,1
CHAR{OB_SPEC(dcolors_tree%,button%-3)}=STR$(temp%)
@draw_rgb_boxes_and_show_color(dcolors_tree%,button%-3)
ENDIF
PAUSE 12
ENDSELECT
UNTIL button%=dcocancl% OR button%=dcook%
'
' Deselect the exit button so it will not be inverse next time it is drawn
OB_STATE(dcolors_tree%,button%)=BCLR(OB_STATE(dcolors_tree%,button%),0)
'
' Tell GEM to redraw the screen area that was occupied by our dialog
~FORM_DIAL(3,0,0,0,0,x%,y%,w%,h%)
'
' Restore color registers
@restore_color_registers(colr$)
'
IF button%=dcook%
' User pressed OK so we update our global color info array
editor_colors%(0)=@get_colors_from_dialog(dcolors_tree%,dcobknum%)
editor_colors%(3)=@get_colors_from_dialog(dcolors_tree%,dcotxnum%)
editor_colors%(2)=@get_colors_from_dialog(dcolors_tree%,dcocrnum%)
editor_colors%(1)=@get_colors_from_dialog(dcolors_tree%,dcoblnum%)
ENDIF
RETURN
> PROCEDURE put_colors_into_dialog(tree%,index%,colr%)
LOCAL red%,green%,blue%
@get_rgb(colr%,red%,green%,blue%)
CHAR{OB_SPEC(tree%,index%)}=STR$(red%)
CHAR{OB_SPEC(tree%,index%+1)}=STR$(green%)
CHAR{OB_SPEC(tree%,index%+2)}=STR$(blue%)
RETURN
FUNCTION get_colors_from_dialog(tree%,index%)
LOCAL red%,green%,blue%,colr%
red%=VAL(CHAR{OB_SPEC(tree%,index%)})
green%=VAL(CHAR{OB_SPEC(tree%,index%+1)})
blue%=VAL(CHAR{OB_SPEC(tree%,index%+2)})
@set_rgb(red%,green%,blue%,colr%)
RETURN colr%
ENDFUNC
> PROCEDURE draw_rgb_boxes_and_show_color(tree%,index%)
LOCAL reg%,r%,g%,b%
IF index%>=dcobknum% AND index%<=dcobknum%+2
index%=dcobknum%
reg%=0
ELSE IF index%>=dcotxnum% AND index%<=dcotxnum%+2
index%=dcotxnum%
reg%=1
ELSE IF index%>=dcocrnum% AND index%<=dcocrnum%+2
index%=dcocrnum%
reg%=3
ELSE IF index%>=dcoblnum% AND index%<=dcoblnum%+2
index%=dcoblnum%
reg%=2
ELSE
GOTO done
ENDIF
~OBJC_DRAW(tree%,index%,10,x%,y%,w%,h%)
~OBJC_DRAW(tree%,index%+1,10,x%,y%,w%,h%)
~OBJC_DRAW(tree%,index%+2,10,x%,y%,w%,h%)
r%=VAL(CHAR{OB_SPEC(tree%,index%)})
g%=VAL(CHAR{OB_SPEC(tree%,index%+1)})
b%=VAL(CHAR{OB_SPEC(tree%,index%+2)})
VSETCOLOR reg%,r%,g%,b%
done:
RETURN
> PROCEDURE get_rgb(colr%,VAR r%,g%,b%)
r%=SHR(colr%,8)
g%=SHR(AND(colr%,&HF0),4)
b%=AND(colr%,&HF)
RETURN
> PROCEDURE set_rgb(r%,g%,b%,VAR colr%)
colr%=SHL(r%,8)+SHL(g%,4)+b%
RETURN
> PROCEDURE save_color_registers(VAR colr$)
LOCAL i%
colr$=""
FOR i%=0 TO 15
colr$=colr$+MKI$(XBIOS(7,i%,-1))
NEXT i%
RETURN
> PROCEDURE restore_color_registers(colr$)
~XBIOS(6,L:V:colr$)
RETURN
'
> PROCEDURE do_mono_color_dialog
LOCAL button%
'
' Initialize the radio buttons
IF editor_colors%(0)<>0
OB_STATE(dcolrmon_tree%,dcmnorm%)=BSET(OB_STATE(dcolrmon_tree%,dcmnorm%),0)
OB_STATE(dcolrmon_tree%,dcminvrs%)=BCLR(OB_STATE(dcolrmon_tree%,dcminvrs%),0)
ELSE
OB_STATE(dcolrmon_tree%,dcmnorm%)=BCLR(OB_STATE(dcolrmon_tree%,dcmnorm%),0)
OB_STATE(dcolrmon_tree%,dcminvrs%)=BSET(OB_STATE(dcolrmon_tree%,dcminvrs%),0)
ENDIF
' animate the dialog
do_dialog(dcolrmon_tree%,0,button%)
IF button%=dcmok%
' Save users new color choice
IF BTST(OB_STATE(dcolrmon_tree%,dcmnorm%),0)
editor_colors%(0)=&H777
editor_colors%(3)=&H0
ELSE
editor_colors%(0)=&H0
editor_colors%(3)=&H777
ENDIF
ENDIF
RETURN
> PROCEDURE do_deflist_dialog
LOCAL button%,i%
' Deselect all radio buttons
FOR i%=0 TO 3
OB_STATE(ddeflist_tree%,dde0%+i%)=BCLR(OB_STATE(ddeflist_tree%,dde0%+i%),0)
NEXT i%
' Select the radio button which corresponds to current DEFLIST value
OB_STATE(ddeflist_tree%,dde0%+default_deflist%)=BSET(OB_STATE(ddeflist_tree%,dde0%+default_deflist%),0)
' Animate the dialog
do_dialog(ddeflist_tree%,0,button%)
IF button%=ddeok%
' Find the selected radio button and update current DEFLIST value
FOR i%=0 TO 3
EXIT IF BTST(OB_STATE(ddeflist_tree%,dde0%+i%),0)
NEXT i%
default_deflist%=i%
ENDIF
RETURN
> PROCEDURE do_llist_dialog
LOCAL button%
'
' Initialize the text fields
CHAR{{OB_SPEC(dllist_tree%,dllpl%)}}=STR$(default_pl%)
CHAR{{OB_SPEC(dllist_tree%,dllll%)}}=STR$(default_ll%)
CHAR{{OB_SPEC(dllist_tree%,dllhe%)}}=default_he$
CHAR{{OB_SPEC(dllist_tree%,dllfo%)}}=default_fo$
CHAR{{OB_SPEC(dllist_tree%,dllin%)}}=default_in$
CHAR{{OB_SPEC(dllist_tree%,dllff%)}}=default_ff$
'
' Animate the dialog box
do_dialog(dllist_tree%,dllpl%,button%)
'
IF button%=dllok%
' save the new information to our global variables
default_pl%=VAL(CHAR{{OB_SPEC(dllist_tree%,dllpl%)}})
default_ll%=VAL(CHAR{{OB_SPEC(dllist_tree%,dllll%)}})
default_he$=CHAR{{OB_SPEC(dllist_tree%,dllhe%)}}
default_fo$=CHAR{{OB_SPEC(dllist_tree%,dllfo%)}}
default_in$=CHAR{{OB_SPEC(dllist_tree%,dllin%)}}
default_ff$=CHAR{{OB_SPEC(dllist_tree%,dllff%)}}
ENDIF
RETURN
> PROCEDURE do_program_dialog
LOCAL t$,b%,button%
'
' Install current program name into dialog text
CHAR{{OB_SPEC(dprogram_tree%,dprtext%)}}=auto_program$
'
DO
' Animate the dialog
do_dialog(dprogram_tree%,dprtext%,button%)
'
EXIT IF button%=dprok% OR button%=dprcancl%
'
' User did not press OK or CANCEL so we know he pressed File Selector button
t$=CHAR{{OB_SPEC(dprogram_tree%,dprtext%)}}
@select_file("GFA","Select auto program for GFABASRO.PRG",t$,b%)
IF b%
IF RIGHT$(t$,1)="\"
CHAR{{OB_SPEC(dprogram_tree%,dprtext%)}}=""
ELSE
CHAR{{OB_SPEC(dprogram_tree%,dprtext%)}}=LEFT$(t$,63)
ENDIF
ENDIF
LOOP
IF button%=dprok%
' Save the new default program name in our global variable
auto_program$=CHAR{{OB_SPEC(dprogram_tree%,dprtext%)}}
ENDIF
RETURN
> PROCEDURE do_dialog(tree%,start%,VAR button%)
' This procedure is a general dialog handler
' tree% is the dialog tree to process
' start% is index of first editable text field (0 if no editable field)
' button% - Exit button index will be returned through this variable
'
LOCAL x%,y%,w%,h%
'
' Center and draw the dialog
~FORM_CENTER(tree%,x%,y%,w%,h%)
~FORM_DIAL(0,0,0,0,0,x%,y%,w%,h%)
~OBJC_DRAW(tree%,0,10,x%,y%,w%,h%)
'
' Animate the dialog
button%=FORM_DO(tree%,start%)
'
' The next line masks off high bit of exit button which is set if button
' was 'touchexit' and user double-clicked.
button%=AND(button%,&H7FFF)
'
' Deselect the exit button so it will not be inverse next time it is drawn
OB_STATE(tree%,button%)=BCLR(OB_STATE(tree%,button%),0)
'
' Tell GEM to redraw the screen area that was occupied by our dialog
~FORM_DIAL(3,0,0,0,0,x%,y%,w%,h%)
RETURN
> PROCEDURE error_exit
' When an error occurs we want to make sure we erase the menu and free
' the resource. We then display an alert box to explain the error.
~MENU_BAR(menu_tree%,0)
~RSRC_FREE()
CLS
~FORM_ALERT(1,ERR$(ERR))
END
RETURN
'
'
'
'
' The following are some general file and path name utilities used by
' this program.
'
> PROCEDURE select_file(extension$,message$,VAR filename$,button%)
LOCAL i%,temppath$,tempname$
tempname$=""
temppath$=""
IF LEN(filename$)>0
@sf_parse_filename(filename$,extension$,temppath$,tempname$)
ENDIF
IF LEN(temppath$)<1
temppath$=@current_directory$+"*."+extension$
ENDIF
IF LEN(message$)>0
@sf_domesg(message$,1,gp$)
ENDIF
FILESELECT temppath$,tempname$,filename$
IF LEN(message$)>0
@sf_domesg(message$,0,gp$)
ENDIF
IF filename$=""
filename$=@directory_only$(temppath$)
button%=0
ELSE
button%=1
ENDIF
RETURN
> PROCEDURE sf_parse_filename(VAR fullname$,extension$,pathname$,filename$)
' This procedure is used by the selectfile() procedure
'
LOCAL i%
i%=LEN(fullname$)
WHILE i%>=1 AND MID$(fullname$,i%,1)<>"\" AND MID$(fullname$,i%,1)<>":"
DEC i%
WEND
IF i%<1
filename$=fullname$
pathname$=""
ELSE
IF i%>=LEN(fullname$)
filename$=""
ELSE
filename$=MID$(fullname$,i%+1)
ENDIF
pathname$=MID$(fullname$,1,i%)+"*."+extension$
ENDIF
RETURN
> PROCEDURE sf_domesg(mesg$,flag%,VAR gp$)
' This procedure is used by the select_file procedure
LOCAL bx%,by%,bw%,bh%,wx%,wy%,ww%,wh%
LOCAL mesgted$,mesgbox$,mesgtree%
mesg$=LEFT$(mesg$,38)+CHR$(0)
mesgted$=MKL$(V:mesg$)+MKL$(0)+MKL$(0)+MKI$(3)+MKI$(0)+MKI$(2)+MKI$(&X1000110000000)+MKI$(0)+MKI$(2)+MKI$(LEN(mesg$))+MKI$(0)
mesgbox$=MKI$(-1)+MKI$(-1)+MKI$(-1)+MKI$(22)+MKI$(32)+MKI$(16)+MKL$(V:mesgted$)+MKI$(0)+MKI$(0)+MKI$(40)+MKI$(2)
mesgtree%=V:mesgbox$
~RSRC_OBFIX(mesgtree%,0)
~WIND_GET(0,4,wx%,wy%,ww%,wh%)
~FORM_CENTER(mesgtree%,bx%,by%,bw%,bh%)
OB_Y(mesgtree%,0)=ADD(wy%,3)
by%=wy%
IF flag%=1
GET bx%,by%,ADD(bx%,bw%),ADD(by%,bh%),gp$
~OBJC_DRAW(mesgtree%,0,5,bx%,by%,bw%,bh%)
ELSE
PUT bx%,by%,gp$,3
ENDIF
RETURN
'
'
FUNCTION new_extension$(oldname$,extension$)
' replaces extension part of oldname$ with extension$ and returns result
' EXAMPLE:
' f$=@new_extension$("D:\MYPROGS\PROGRAM.LST", "BAS")
' after this call the variable f$ will contain "D:\MYPROGS\PROGRAM.BAS"
'
LOCAL i%
i%=LEN(oldname$)
WHILE i%>1 AND MID$(oldname$,i%,1)<>"." AND MID$(oldname$,i%,1)<>"\"
DEC i%
WEND
IF MID$(oldname$,i%,1)<>"."
RETURN oldname$+"."+extension$
ELSE
RETURN MID$(oldname$,1,i%)+extension$
ENDIF
ENDFUNC
'
'
FUNCTION filename_only$(fullpath$)
' takes complete path name in fullpath$ and returns only the file name
' EXAMPLE:
' f$=@filename_only$("B:\BASIC\PROGRAMS\MYPROG.BAS")
' after this call f$ will contain "MYPROG.BAS"
'
LOCAL i%
i%=LEN(fullpath$)
WHILE i%>=1 AND MID$(fullpath$,i%,1)<>"\"
DEC i%
WEND
IF i%=LEN(fullpath$)
RETURN ""
ELSE
RETURN MID$(fullpath$,i%+1)
ENDIF
ENDFUNC
'
'
FUNCTION directory_only$(fullpath$)
' takes complete path name in fullpath$ and returns path without file name
' EXAMPLE:
' f$=@directory_only$("B:\BASIC\PROGRAMS\MYPROG.BAS")
' after this call f$ will contain "B:\BASIC\PROGRAMS\"
'
LOCAL i%
i%=LEN(fullpath$)
WHILE i%>=1 AND MID$(fullpath$,i%,1)<>"\"
DEC i%
WEND
IF (i%<1)
RETURN ""
ELSE
RETURN MID$(fullpath$,1,i%)
ENDIF
ENDFUNC
'
'
FUNCTION current_directory$
' Returns current (default) directory
' EXAMPLE:
' d$=@current_directory$
' After this call the variable p$ will contain the default directory name
'
RETURN CHR$(GEMDOS(25)+65)+":"+DIR$(GEMDOS(25)+1)+"\"
ENDFUNC
'
'